<template>
  <div>

    <el-card class="box-card" shadow="hover" v-for="(post,index) in posts" :key="index">
      <el-row :gutter="15">
        <el-col :span="3">
          <div class="avatar">
            <a href="#">
              <img class="round" src="../assets/avatar.jpg" alt="">
            </a>
          </div>
        </el-col>
        <el-col :span="21" class="feed">
          <div class="name">mircool</div>
          <div class="time">{{post.updatedAt}} </div>
          <div class="content">
            {{post._serverData.content}}
            <img src="https://wx4.sinaimg.cn/mw690/49393842gy1fuaq74oz9dj20zk0qodme.jpg" alt="">
          </div>
          <div class="toolbar">
            <el-row>
              <el-col :span="8" class="tool">
                <i class="fas fa-share-square"></i>
              </el-col>
              <el-col :span="8" class="tool">
                <i class="fas fa-comment-alt"></i>
              </el-col>
              <el-col :span="8" class="tool">
                <i class="fas fa-thumbs-up"></i>
              </el-col>
            </el-row>

          </div>
        </el-col>
      </el-row>
    </el-card>

  </div>
</template>

<script>
export default {
  data() {
    return {
      posts: {}
    };
  },
  mounted() {
    this.get_posts();
  },
  methods: {
    get_posts() {
      let currentUser = this.$AV.User.current();

      let query = new this.$AV.Query("Posts");
      query.equalTo("user_id", currentUser.id);
      query.find().then(
        (results) => {
          this.posts = results;
          console.log(this.posts);
        },
        (error) => {}
      );
    }
  }
};
</script>

<style scoped>
.box-card {
  margin-bottom: 10px;
}

.avatar img {
  width: 100%;
  height: 100%;
}

.feed > * {
  margin-bottom: 10px;
}

.name {
  font-size: 18px;
  font-weight: 600;
}

.time {
  font-size: 12px;
  color: #c0c4cc;
}

.toolbar {
  margin-top: 30px;
  text-align: center;
}

.tool i {
  font-size: 20px;
  color: #c0c4cc;
}

.tool:hover i {
  color: #303133;
}

.content {
  line-height: 30px;
}

.content img {
  width: 100%;
  height: 100%;
}
</style>


